<script setup>
import {pageofficeOpenFile} from "@/plugins/pageoffice/pageoffice-common.js";
import {backExchangeDocList} from "@/utils/backList.js";

const {proxy} = getCurrentInstance()
const {urgency} = proxy.useDict(["urgency", false])
const docFinalFileInfo = inject('getDocFinalFileInfo')
const props = defineProps({
  documentInfo: {
    type: Object
  },
  recordId: {
    type: Number
  },
})
const documentViewForm = ref({})

watch(() => [props.documentInfo], ([newValue1], [oldValue1]) => {
  if (newValue1 !== oldValue1) {
    documentViewForm.value = props.documentInfo
  }
})

function openFinalFile() {
  const recordId = props.recordId
  const fileInfo = JSON.stringify(docFinalFileInfo.value)
  pageofficeOpenFile('/document/exchange/common/openFinalFile/' + recordId, fileInfo)
}

</script>

<template>
  <el-row>
    <el-col :span="24">
      <el-form :model="documentViewForm" label-position="top" label-width="auto">
        <el-row>
          <el-form-item>
            <el-button @click="backExchangeDocList">返 回</el-button>
            <el-button @click="openFinalFile" type="primary">打开正文</el-button>
            <slot></slot>
          </el-form-item>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="紧急程度" prop="urgency">
              <el-select v-model="documentViewForm.urgency" placeholder="请选择" disabled>
                <el-option
                    v-for="dict in urgency"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="密级" prop="secretLevel">
              <el-input disabled v-model="documentViewForm.secretLevel"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="发文标题" prop="subject">
              <el-input disabled v-model="documentViewForm.subject"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="发文字号" prop="docNo">
              <el-input disabled v-model="documentViewForm.docNo"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="发文单位" prop="sendUnit">
              <el-input disabled v-model="documentViewForm.sendUnit"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="发文用户" prop="userName">
              <el-input disabled v-model="documentViewForm.userName"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="主送单位" prop="mainSendUnit">
              <el-input disabled v-model="documentViewForm.mainSendUnit"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="抄送单位" prop="copySendUnit">
              <el-input disabled v-model="documentViewForm.copySendUnit"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="公文摘要" prop="docPrecis">
              <el-input disabled type="textarea" :rows="2" v-model="documentViewForm.docPrecis" />
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="发文意见" prop="sendUnitAdvice">
              <el-input disabled type="textarea" :rows="2" v-model="documentViewForm.sendUnitAdvice" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="限办日期" prop="endDate">
              <el-input disabled v-model="documentViewForm.endDate" />
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="印发日期" prop="printDate">
              <el-input disabled v-model="documentViewForm.printDate" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12" :xs="24">
            <el-form-item label="印发机关" prop="printUnit">
              <el-input disabled v-model="documentViewForm.printUnit" />
            </el-form-item>
          </el-col>
          <el-col :span="12" :xs="24">
            <el-form-item label="印发份数" prop="printCount">
              <el-input disabled v-model="documentViewForm.printCount" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="30">
          <el-col :span="24">
            <el-form-item label="说明">
              <el-input disabled v-model="documentViewForm.memo" type="textarea"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

    </el-col>
  </el-row>
</template>

<style scoped lang="scss">
:deep(.el-input.is-disabled .el-input__wrapper) {
  .el-input__inner {
    -webkit-text-fill-color: #606266;
  }
}

:deep(.el-textarea.is-disabled) {
  .el-textarea__inner {
    -webkit-text-fill-color: #606266;
  }
}

</style>